package gov.child.dao;

import gov.child.dao.exception.EntityDeleteException;
import gov.child.dao.exception.EntityQueryException;
import gov.child.dao.exception.EntitySaveException;
import gov.child.dao.exception.EntityUpdateException;
import gov.child.entities.po.EDepartment;
import gov.child.entities.po.EEnterpriseDeclareForm;
import gov.child.entities.po.EUser;
import gov.child.entities.vo.Page;

import java.util.List;

/**
 * @author fzh
 * @since 2017/9/10
 */
public interface EnterpriseDeclareFormDao extends Pageable {

    EEnterpriseDeclareForm findById(Integer id) throws EntityQueryException;

    EEnterpriseDeclareForm findByUniformCode(String uniformCode) throws EntityQueryException;

    default List findByUser(EUser user) throws EntityQueryException {
        return findByUser(user, Page.singlePage());
    }

    default List findByUser(EUser user, Page page) throws EntityQueryException {
        return findByUserId(user.getId(), page);
    }

    default List findByUserId(Integer userId) throws EntityQueryException {
        return findByUserId(userId, Page.singlePage());
    }

    default List findByDepartment(EDepartment department) throws EntityQueryException {
        return findByDepartmentId(department.getId(), Page.singlePage());
    }

    default List findByDepartment(EDepartment department, Page page) throws EntityQueryException {
        return findByDepartmentId(department.getId(), page);
    }

    default List findByDepartmentId(Integer id) {
        return findByDepartmentId(id, Page.singlePage());
    }

    List findByDepartmentId(Integer id, Page page);

    List findByUserId(Integer userId, Page page) throws EntityQueryException;

    void save(EEnterpriseDeclareForm form) throws EntitySaveException;

    void delete(EEnterpriseDeclareForm form) throws EntityDeleteException;

    void deleteByUniformCode(String uniformCode) throws EntityDeleteException;

    void update(EEnterpriseDeclareForm form) throws EntityUpdateException;
}
